﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;
namespace version1
{
    public class GiaoDien
    {
        private Texture2D _sprite;

        public Texture2D Sprite
        {
            get { return _sprite; }
            set { _sprite = value; }
        }
        private Vector2 _size = new Vector2(0, 0);

        public Vector2 Size
        {
            get { return _size; }
            set { _size = value; }
        }

        public int _nsprite;

        public int Nsprite
        {
            get { return _nsprite; }
            set { _nsprite = value; }
        }

        public Vector2 _position;

        public Vector2 Position
        {
            get { return _position; }
            set { _position = value; }
        }


        public GiaoDien(ContentManager content, string str, Vector2 position)
        {
            Sprite = content.Load<Texture2D>("GiaoDien//" + str);
            Position = position;
        }

        public void Draw(SpriteBatch spritebatch, GameTime gameTime)
        {
            //spritebatch.Draw(_sprite[_isprite], _position, Color.White);
            Rectangle rec = new Rectangle();
            //Thay doi kich thuoc hinh
            if (_size.X == 0)
                rec = new Rectangle((int)_position.X, (int)_position.Y, _sprite.Width, _sprite.Height);
            else
                rec = new Rectangle((int)_position.X, (int)_position.Y, (int)_size.X, (int)_size.Y);
            spritebatch.Draw(_sprite, rec, Color.White);
        }
        public void Update(GameTime gametime, int x, int y)
        {
            Vector2 newpos = new Vector2(Position.X - x, Position.Y - y);
            Position = newpos;
        }
    }
}
